package com.zmovie.admin.controller.movie;

import com.zmovie.common.response.CommonReturnType;
import com.zmovie.framework.domain.ActorMovie;
import com.zmovie.framework.service.ActorMovieService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

/**
 * @author 挚爱之夕
 * @version 1.0
 * @implSpec 电影角色模块
 * @since 2023-12-08 11:53
 */
@Controller
@RequestMapping("/movie/actor")
@Api(tags = "电影角色模块")
public class ActorMovieController {
    @Autowired
    private ActorMovieService actorMovieService;

    @PostMapping
    @ApiOperation("添加电影人员")
    @ResponseBody
    public Object addActorToMovie(@Validated ActorMovie actorMovie){
        actorMovieService.save(actorMovie);
        return CommonReturnType.success("添加成功!");
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除电影人员")
    @ResponseBody
    public Object deleteActorFromMovie(@PathVariable("id") @NotNull Integer id){
        actorMovieService.removeById(id);
        return CommonReturnType.success("删除成功!");
    }
}
